import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import configuration from 'config/configuration';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { DataSource } from 'typeorm';
@Module({
  imports: [
    ConfigModule.forRoot({
      load: [configuration], //自定义配置
      //envFilePath: '.development.env',默认会查找根目录下.env 文件，要指定 .env 文件的另一个路径，请将可选的选项对象中的 envFilePath 属性设置为所需路径
      //envFilePath: ['.env.development.local', '.env.development'] 多个env文件
      //ignoreEnvFile: true, //禁用环境变量加载
      isGlobal: true, //全局使用模块
    }),
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: '123456',
      database: 'test',
      entities: [],
      synchronize: true,
      // autoLoadEntities: true, //自动加载实体
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {
  constructor(private dataSource: DataSource) {}
}
